import Vue from 'vue'
import Router from 'vue-router'

// 获取原型对象上的push函数
const originalPush = Router.prototype.push
// 修改原型对象中的push方法
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'home',
      redirect: '/loading',
    },
    {
      path: '/loading',
      name: 'loading',
      component: () => import('@/pages/loading/LoadingView'),
    },
    {
      path: '/daily',
      name: 'daily',
      component: () => import('@/pages/daily/DailyView'),
    },
    {
      path: '/monthly',
      name: 'monthly',
      component: () => import('@/pages/monthly/MonthlyView'),
    },
    {
      path: '/setting',
      name: 'setting',
      component: () => import('@/pages/setting/SettingView'),
    },
  ],
})
